<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class UserVipFreeOpeCountLog extends Model
{
    const ADD_OPE = 1; //新增
    const EXPEND_OPE = 2; //花费


    protected $table = 'user_vip_free_ope_count_logs';
    protected $fillable = [
        'user_id',
        'ope',
        'free_home_help_ope_count',
        'free_home_help_remain_count',
        'free_resource_ope_count',
        'free_resource_remain_count',
        'free_algorithm_sources_ope_count',
        'free_algorithm_sources_remain_count',
        'resource_id',
        'remark',
    ];

    public $timestamps = true;

    public static function getLatestLog($userId)
    {
        return (new static())::where('user_id', $userId)
            ->orderBy('id', 'desc')
            ->first();
    }
}
